angular.module('app').controller('detailPostCtrl', 
['$scope', '$rootScope', 'http', 'stateV',
function($scope, $rootScope,http, stateV) 
{	
	function ngInit(){
		$rootScope.htmlshow = false;
		$scope.post = stateV.get();

		// $scope.post.condition = JSON.stringify($scope.post.condition)
		$scope.post.result = JSON.stringify($scope.post.result)
	}
	

	// 修改商品
	$scope.updatePost = function(){
		console.log($scope.post)
		if(!angular.isObject(JSON.parse($scope.post.condition))){
			alert("开奖条件格式错误")
			return false;
		}
		if(!angular.isObject(JSON.parse($scope.post.ok))){
			alert("活动条件格式错误")
			return false;
		}
		var reqUrl = '/activity/updateActivity';
		http.post(reqUrl, $scope.post, function(data, status){
			console.log(data, status)
			if(data.status==200){
				alert(data.msg);
			}
		})
	}

	 ngInit();
}]);